﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;

namespace Agility.Wcf.ClientProxy
{
    public class CookieManagerEndpointBehavior : IEndpointBehavior
    {
        private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

        public CookieManagerMessageInspector CookieManager 
        {
            get { return CookieManagerMessageInspector.GetInstance(); }
            private set { }
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
            logger.Debug("--> Entering AddBindingParameters");
            logger.Debug("<-- Leaving AddBindingParameters");
            return;
        }

        public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
        {
            logger.Debug("--> Entering ApplyClientBehavior");
            clientRuntime.MessageInspectors.Add(this.CookieManager);
            logger.Debug("<-- Leaving ApplyClientBehavior");
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
        {
            logger.Debug("--> Entering ApplyDispatchBehavior");
            logger.Debug("<-- Leaving ApplyDispatchBehavior");
            return;
        }

        public void Validate(ServiceEndpoint endpoint)
        {
            logger.Debug("--> Entering Validate");
            logger.Debug("<-- Leaving Validate");
            return;
        }
    }
}
